<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>ip::basic_endpoint::basic_endpoint (2 of 5 overloads)</title>
    <link rel="stylesheet" href="../../../../boostbook.css" type="text/css">
    <meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
    <link rel="home" href="../../../../index.html" title="Asio">
    <link rel="up" href="../basic_endpoint.html" title="ip::basic_endpoint::basic_endpoint">
    <link rel="prev" href="overload1.html" title="ip::basic_endpoint::basic_endpoint (1 of 5 overloads)">
    <link rel="next" href="overload3.html" title="ip::basic_endpoint::basic_endpoint (3 of 5 overloads)">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%">
    <tr>
        <td valign="top"><img alt="asio C++ library" width="250" height="60" src="../../../../asio.png"></td>
    </tr>
</table>
<hr>
<div class="spirit-nav">
    <a accesskey="p" href="overload1.html"><img src="../../../../prev.png" alt="Prev"></a><a accesskey="u"
                                                                                             href="../basic_endpoint.html"><img
        src="../../../../up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img
        src="../../../../home.png" alt="Home"></a><a accesskey="n" href="overload3.html"><img src="../../../../next.png"
                                                                                              alt="Next"></a>
</div>
<div class="section">
    <div class="titlepage">
        <div>
            <div><h5 class="title">
                <a name="asio.reference.ip__basic_endpoint.basic_endpoint.overload2"></a><a class="link"
                                                                                            href="overload2.html"
                                                                                            title="ip::basic_endpoint::basic_endpoint (2 of 5 overloads)">ip::basic_endpoint::basic_endpoint
                (2 of 5 overloads)</a>
            </h5></div>
        </div>
    </div>
    <p>
        Construct an endpoint using a port number, specified in the host's byte
        order. The IP address will be the any address (i.e. INADDR_ANY or in6addr_any).
        This constructor would typically be used for accepting new connections.
    </p>
    <pre class="programlisting"><span class="identifier">basic_endpoint</span><span class="special">(</span>
    <span class="keyword">const</span> <span class="identifier">InternetProtocol</span> <span
                class="special">&amp;</span> <span class="identifier">internet_protocol</span><span
                class="special">,</span>
    <span class="identifier">port_type</span> <span class="identifier">port_num</span><span class="special">);</span>
</pre>
    <h6>
        <a name="asio.reference.ip__basic_endpoint.basic_endpoint.overload2.h0"></a>
        <span><a name="asio.reference.ip__basic_endpoint.basic_endpoint.overload2.examples"></a></span><a class="link"
                                                                                                          href="overload2.html#asio.reference.ip__basic_endpoint.basic_endpoint.overload2.examples">Examples</a>
    </h6>
    <p>
        To initialise an IPv4 TCP endpoint for port 1234, use:
    </p>
    <pre class="programlisting"><span class="identifier">asio</span><span class="special">::</span><span
            class="identifier">ip</span><span class="special">::</span><span class="identifier">tcp</span><span
            class="special">::</span><span class="identifier">endpoint</span> <span class="identifier">ep</span><span
            class="special">(</span><span class="identifier">asio</span><span class="special">::</span><span
            class="identifier">ip</span><span class="special">::</span><span class="identifier">tcp</span><span
            class="special">::</span><span class="identifier">v4</span><span class="special">(),</span> <span
            class="number">1234</span><span class="special">);</span>
</pre>
    <p>
        To specify an IPv6 UDP endpoint for port 9876, use:
    </p>
    <pre class="programlisting"><span class="identifier">asio</span><span class="special">::</span><span
            class="identifier">ip</span><span class="special">::</span><span class="identifier">udp</span><span
            class="special">::</span><span class="identifier">endpoint</span> <span class="identifier">ep</span><span
            class="special">(</span><span class="identifier">asio</span><span class="special">::</span><span
            class="identifier">ip</span><span class="special">::</span><span class="identifier">udp</span><span
            class="special">::</span><span class="identifier">v6</span><span class="special">(),</span> <span
            class="number">9876</span><span class="special">);</span>
</pre>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%">
    <tr>
        <td align="left"></td>
        <td align="right">
            <div class="copyright-footer">Copyright © 2003-2022 Christopher M. Kohlhoff<p>
                Distributed under the Boost Software License, Version 1.0. (See accompanying
                file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
            </p>
            </div>
        </td>
    </tr>
</table>
<hr>
<div class="spirit-nav">
    <a accesskey="p" href="overload1.html"><img src="../../../../prev.png" alt="Prev"></a><a accesskey="u"
                                                                                             href="../basic_endpoint.html"><img
        src="../../../../up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img
        src="../../../../home.png" alt="Home"></a><a accesskey="n" href="overload3.html"><img src="../../../../next.png"
                                                                                              alt="Next"></a>
</div>
</body>
</html>
